﻿include_directories(${CMAKE_CURRENT_LIST_DIR})
include_directories(${CMAKE_CURRENT_LIST_DIR}/../)

aux_source_directory(${CMAKE_CURRENT_LIST_DIR} DIR_LIB_SRC)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/../elib DIR_ELIB_SRC)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/bstring DIR_BSTRING_SRC)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/util DIR_UTIL_SRC)

add_library(commobj_static STATIC
	${DIR_LIB_SRC}
	${DIR_ELIB_SRC}
    ${DIR_BSTRING_SRC}
    ${DIR_UTIL_SRC}
)

add_library(commobj SHARED
	${DIR_LIB_SRC}
	${DIR_ELIB_SRC}
    ${DIR_BSTRING_SRC}
    ${DIR_UTIL_SRC}
	Source_commobj.def
)

target_compile_options(commobj_static PRIVATE
    $<$<COMPILE_LANGUAGE:C>:/Zi>
    $<$<COMPILE_LANGUAGE:CXX>:/Zi>
    $<$<COMPILE_LANGUAGE:C>:/GS->
    $<$<COMPILE_LANGUAGE:CXX>:/GS->
    $<$<COMPILE_LANGUAGE:C>:/EHs-c->
    $<$<COMPILE_LANGUAGE:CXX>:/EHs-c->
)

target_compile_options(commobj PRIVATE
    $<$<COMPILE_LANGUAGE:C>:/Zi>
    $<$<COMPILE_LANGUAGE:CXX>:/Zi>
    $<$<COMPILE_LANGUAGE:C>:/GS->
    $<$<COMPILE_LANGUAGE:CXX>:/GS->
    $<$<COMPILE_LANGUAGE:C>:/EHs-c->
    $<$<COMPILE_LANGUAGE:CXX>:/EHs-c->
)

target_link_libraries(commobj_static PRIVATE legacy_stdio_definitions.lib)
target_link_libraries(commobj PRIVATE legacy_stdio_definitions.lib)

#set_target_properties(commobj PROPERTIES SUFFIX ".fne")

set_target_properties(commobj PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:DebugDLL>")
set_target_properties(commobj_static PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:DebugDLL>")

target_compile_definitions(commobj PRIVATE commobj_EXPORTS __E_FNENAME=commobj)
target_compile_definitions(commobj_static PRIVATE __E_STATIC_LIB __E_FNENAME=commobj)

target_compile_definitions(commobj PRIVATE _NO_CRT_STDIO_INLINE _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS __WATCOMC__ BSTRLIB_DONT_USE_VIRTUAL_DESTRUCTOR BSTRLIB_DOESNT_THROW_EXCEPTIONS _CRT_SECURE_NO_WARNINGS)
target_compile_definitions(commobj_static PRIVATE _NO_CRT_STDIO_INLINE _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS __WATCOMC__ BSTRLIB_DONT_USE_VIRTUAL_DESTRUCTOR BSTRLIB_DOESNT_THROW_EXCEPTIONS _CRT_SECURE_NO_WARNINGS)
